package com.design.springboot.booksharing.component;

import com.design.springboot.booksharing.interceptor.AuthenticationInterceptor;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * WebMvc 配置
 */
@ServletComponentScan({"com.design.springboot.booksharing"})
@Configuration("commonWebMvcConfiguration")
public class WebMvcConfiguration implements WebMvcConfigurer {
    @Resource
    AuthenticationInterceptor authenticationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authenticationInterceptor)
            .addPathPatterns("/**");
    }
}
